import React from 'react'
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { TabsState, TabItem } from '../type'
// import { HomeFilled } from '@ant-design/icons'
import { HOME_URL } from '@/config/config'

const tabState: TabsState = {
  tabsActive: HOME_URL,
  tabsList: [{ label: '首页', key: HOME_URL }]
}

const tabsSlice = createSlice({
  name: 'tabs',
  initialState: tabState,
  reducers: {
    setTabsList(state: TabsState, { payload }: PayloadAction<TabItem[]>) {
      state.tabsList = payload
    },
    setTabsActive(state: TabsState, { payload }: PayloadAction<string>) {
      state.tabsActive = payload
    }
  }
})

export const { setTabsList, setTabsActive } = tabsSlice.actions
export default tabsSlice.reducer
